﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HFController;
namespace HFWebApp.news
{
    public partial class NewsContent : BagePages
    {
        public hf.Model.News news = new hf.Model.News();

        public hf.Model.News nNews = null;

        public hf.Model.News lNews = null;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                string NewsID = this.GetQuery("NewsID");
                if (NewsID == "")
                {
                    Response.Write("参数错误");
                    Response.End();
                }
                else {
                    news = NewsController.getController().getNewsModel(int.Parse(NewsID));

                    List<hf.Model.News> newsList = NewsController.getController().getNewsList(10, "TopicID = " + news.TopicID.ToString());
                    if (newsList.Count > 0)
                    {
                        for (int i = 0; i < newsList.Count; i++)
                        {
                            if (newsList[i].ID == news.ID)
                            {
                                if((i - 1) >=0 )
                                    nNews = newsList[i - 1];

                                if((i + 1) < newsList.Count)
                                    lNews = newsList[i + 1];

                                break;
                            }
                        }
                    }
                }
            }
        }
    }
}